﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Input;

namespace RobotGameData
{
    public class InputState
    {
        #region Fields

        private  KeyboardState currentKeyboardStates;
        private  KeyboardState lastKeyboardStates;
        private MouseState currentMousestate;
        #endregion

        #region Initialization

        public InputState()
        {
            CurrentKeyboardStates = new KeyboardState();
            LastKeyboardStates = new KeyboardState();
        }

        public KeyboardState CurrentKeyboardStates
        {
            get { return currentKeyboardStates; }
            set { currentKeyboardStates = value; }
        }

        public KeyboardState LastKeyboardStates
        {
            get { return lastKeyboardStates; }
            set { lastKeyboardStates = value; }
        }

        public MouseState CurrentMousestate
        {
            get { return currentMousestate; }
            set { currentMousestate = value; }
        }

        #endregion

        #region Public Methods

        public void Update()
        {

            LastKeyboardStates = CurrentKeyboardStates;
            CurrentKeyboardStates = Keyboard.GetState();
            currentMousestate = Mouse.GetState();

        }

        public bool IsNewKeyPress(Keys key)
        {

            return (CurrentKeyboardStates.IsKeyDown(key) &&
                    LastKeyboardStates.IsKeyUp(key));
        }

        public bool IsLeftButtonPress()
        {

            return (currentMousestate.LeftButton == ButtonState.Pressed);
                
        }

        public bool IsRightButtonPress()
        {

            return (currentMousestate.RightButton == ButtonState.Pressed);
        }

        #endregion
    }
}
